package com.ma4567.remotecontroller.UserManager;

public class UserPermission {
    public boolean Root;

    public boolean DownloadFile;
    public boolean DeleteFile;
    public boolean UploadFile;

    public boolean RemoteControl;

    public UserPermission() {}

    public UserPermission(User user) {
        this.Root = user.Root;
        this.DownloadFile = user.DownloadFile;
        this.DeleteFile = user.DeleteFile;
        this.UploadFile = user.UploadFile;
        this.RemoteControl = user.RemoteControl;
    }

    public UserPermission(boolean Root, boolean DownloadFile, boolean DeleteFile, boolean UploadFile, boolean RemoteControl) {
        this.Root = Root;
        this.DownloadFile = DownloadFile;
        this.DeleteFile = DeleteFile;
        this.UploadFile = UploadFile;
        this.RemoteControl = RemoteControl;
    }

    public UserPermission(UserPermission otherUser) {
        if(otherUser == null) {
            this.Root = false;
            this.DownloadFile = false;
            this.DeleteFile = false;
            this.UploadFile = false;
            this.RemoteControl = false;
        }
        else {
            this.Root = otherUser.Root;
            this.DownloadFile = otherUser.DownloadFile;
            this.DeleteFile = otherUser.DeleteFile;
            this.UploadFile = otherUser.UploadFile;
            this.RemoteControl = otherUser.RemoteControl;
        }
    }

    public static boolean IsPermissionExist(String PermissionName) {
        return switch (PermissionName) {
            case "DownloadFile", "RemoteControl", "Root", "DeleteFile", "UploadFile" -> true;
            default -> false;
        };
    }
}
